struct ListNode* deleteDuplicates(struct ListNode* head){
    if (head == NULL) return head;
    struct ListNode* dummy =(struct ListNode*)malloc(sizeof(struct ListNode));
    dummy->next=head;
    struct ListNode *pre = dummy;
    struct ListNode *cur = dummy->next;
            while (cur != NULL)
            {
                if (cur->next!=NULL && cur->val == cur->next->val)
                {
                    int dupVal = cur->val;
                    while (cur!=NULL && cur->val == dupVal)
                    {
                        cur = cur->next;
                    }
                    if (cur == NULL) pre->next = cur;
                }
                else
                {
                    pre->next = cur;
                    pre = pre->next;
                    cur = cur->next;
                }
            }
            return dummy->next;
}